package no.uio.inf5750.wsclient.javarosaclient;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

import org.javarosa.core.Context;
import org.javarosa.core.api.Constants;
import org.javarosa.core.api.IActivity;
import org.javarosa.core.api.IShell;

import de.enough.polish.ui.Form;

public class NotImplementedActivity
    implements IActivity, CommandListener
{
    private IShell shell;

    public NotImplementedActivity( IShell shell )
    {
        setShell( shell );
    }

    public void contextChanged( Context globalContext )
    {
        // TODO Auto-generated method stub

    }

    public void destroy()
    {
        // TODO Auto-generated method stub

    }

    public Context getActivityContext()
    {
        // TODO Auto-generated method stub
        return null;
    }

    public void halt()
    {
        // TODO Auto-generated method stub

    }

    public void resume( Context globalContext )
    {
        // TODO Auto-generated method stub

    }

    public void setShell( IShell shell )
    {
        this.shell = shell;
    }

    public void start( Context context )
    {
        //#style notImplementedScreen, baseScreen 
        Form form = new Form( null );

        form.addCommand( new Command( "Back", Command.BACK, 0 ) );

        //#style notImplementedText, baseText
        form.append( "Sorry, activity '" + context.getElement( "selected activity name" ) + "' not yet implemented." );

        form.setCommandListener( this );
        shell.setDisplay( this, Util.createIView( form ) );
    }

    public void commandAction( Command arg0, Displayable arg1 )
    {
        // Just return for all commands 
        shell.returnFromActivity( this, Constants.ACTIVITY_COMPLETE, null );
    }

}
